package com.seguriapp.entities;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.seguriapp.base.BaseEntity;
import com.seguriapp.util.Util;

/**
 * Represents a Complaint entity.
 * 
 * @author Tania Gonzales(taniadgv@gmail.com)
 */
@Entity
@Table(name = "Complaint")
public class Complaint extends BaseEntity {

  private static final long serialVersionUID = -6385564353350333469L;

  @Id
  @GeneratedValue
  private Long id;

  private String names;
  private String lastNames;
  private String dni;
  private String address;
  private String email;
  private String phone;
  private String description;
  private Date crimeDate;
  private Date complaintDate;
  private double crimeLongitude;
  private double crimeLatitude;
  private double complaintLongitude;
  private double complaintLatitude;
  private boolean mapVisivility;
  private int devideId;

  @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
  @JoinColumn(nullable = false, name = "categoryId")
  private CrimeCategory category;

  @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
  @JoinColumn(nullable = false, name = "entityId")
  private SeguriAppEntity entity;

  public Long getId() {
    return id;
  }

  public String getNames() {
    return names;
  }

  public String getLastNames() {
    return lastNames;
  }

  public String getDni() {
    return dni;
  }

  public String getAddress() {
    return address;
  }

  public String getEmail() {
    return email;
  }

  public String getPhone() {
    return phone;
  }

  public String getDescription() {
    return description;
  }

  public Date getCrimeDate() {
    return crimeDate;
  }

  public Date getComplaintDate() {
    return complaintDate;
  }

  public double getCrimeLongitude() {
    return crimeLongitude;
  }

  public double getCrimeLatitude() {
    return crimeLatitude;
  }

  public double getComplaintLongitude() {
    return complaintLongitude;
  }

  public double getComplaintLatitude() {
    return complaintLatitude;
  }

  public boolean getMapVisivility() {
    return mapVisivility;
  }

  public CrimeCategory getCategory() {
    return category;
  }

  public SeguriAppEntity getEntity() {
    return entity;
  }

  public void setId(final Long id) {
    this.id = id;
  }

  public void setNames(final String names) {
    this.names = names;
  }

  public void setLastNames(final String lastNames) {
    this.lastNames = lastNames;
  }

  public void setDni(final String dni) {
    this.dni = dni;
  }

  public void setAddress(final String address) {
    this.address = address;
  }

  public void setEmail(final String email) {
    this.email = email;
  }

  public void setPhone(final String phone) {
    this.phone = phone;
  }

  public void setDescription(final String description) {
    this.description = description;
  }

  public void setCrimeDate(final Date crimeDate) {
    this.crimeDate = crimeDate;
  }

  public void setComplaintDate(final Date complaintDate) {
    this.complaintDate = complaintDate;
  }

  public void setCrimeLongitude(final double crimeLongitude) {
    this.crimeLongitude = crimeLongitude;
  }

  public void setCrimeLatitude(final double crimeLatitude) {
    this.crimeLatitude = crimeLatitude;
  }

  public void setComplaintLongitude(final double complaintLongitude) {
    this.complaintLongitude = complaintLongitude;
  }

  public void setComplaintLatitude(final double complaintLatitude) {
    this.complaintLatitude = complaintLatitude;
  }

  public void setMapVisivility(final boolean mapVisivility) {
    this.mapVisivility = mapVisivility;
  }

  public void setCategory(final CrimeCategory category) {
    this.category = category;
  }

  public void setEntity(final SeguriAppEntity entity) {
    this.entity = entity;
  }

  public int getDevideId() {
    return devideId;
  }

  public void setDevideId(final int devideId) {
    this.devideId = devideId;
  }

  public Map<String, Object> toJsonString() {
    final Map<String, Object> map = new LinkedHashMap<String, Object>();
    map.put("id", id);
    map.put("names", names);
    map.put("lastNames", lastNames);
    map.put("dni", dni);
    map.put("address", address);
    map.put("email", email);
    map.put("phone", phone);
    map.put("description", description);
    map.put("crimeDate", Util.parseDateToString(crimeDate));
    map.put("complaintDate", Util.parseDateToString(complaintDate));
    map.put("crimelatitude", crimeLatitude);
    map.put("crimelongitude", crimeLongitude);
    map.put("complaintlatitude", complaintLatitude);
    map.put("complaintlongitude", complaintLongitude);
    map.put("mapVisivility", mapVisivility);
    map.put("category", category.toJsonString());
    map.put("entity", entity.toJsonString());
    return map;
  }

}
